#include "addprivilegedialog.h"
#include "ui_addprivilegedialog.h"

AddPrivilegeDialog::AddPrivilegeDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AddPrivilegeDialog)
{
    ui->setupUi(this);
}

/*
AddPrivilegeDialog::AddPrivilegeDialog(QWidget *parent, QListWidget *list) :
    QDialog(parent),
    ui(new Ui::AddPrivilegeDialog)
{
    ui->setupUi(this);

    ui->userList = new QListWidget(this);

    QStringList strs;
    QList<QListWidgetItem *> items = list->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);
    foreach(QListWidgetItem *item, items) {
        strs.append(item->text());
    }

    //ui->userList->addItems(strs);
}*/

AddPrivilegeDialog::~AddPrivilegeDialog()
{
    delete ui;
}

void AddPrivilegeDialog::on_selectButton_clicked()
{
    qDebug() << "selected Item" + ui->userList->currentItem()->text();
    emit sendSelectedUser(ui->userList->currentItem()->text());
    this->close();
}

void AddPrivilegeDialog::on_cancelButton_clicked()
{
    this->close();
}

void AddPrivilegeDialog::receiveUserList(QListWidget *listFromManagementWindow)
{
    //list = listFromManagementWindow;
    foreach(QListWidgetItem* listItem, listFromManagementWindow->findItems("*", Qt::MatchWildcard))
    {
        ui->userList->addItem(listItem->text());
    }

}
